package org.jeecg.common.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author:wly
 * @Date:2021/9/18
 * @Describtion: 时间格式化工具类
 */
public class DateFormatUtil {
    //格式化时间yyyy-MM-dd
    public static String formatDateyyMMdd(Long date) {
        if(date != null){
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            return format.format(new Date(date));
        }else{
            return "";
        }
    }

    //格式化时间yyyy-MM-dd HH:mm:ss
    public static String formatDateyyMMddHHmmss(Long date) {
        if(date != null){
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return format.format(new Date(date));
        }else{
            return "";
        }
    }

    //格式化时间yyyy-MM-dd
    public static String formatDateyyMMdd(Date date) {
        if(date != null){
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            return format.format(date);
        }else{
            return "";
        }
    }

    //格式化时间yyyy-MM-dd HH:mm:ss
    public static String formatDateyyMMddHHmmss(Date date) {
        if(date != null){
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return format.format(date);
        }else{
            return "";
        }
    }

}
